export function addSubscription(subscriptions, callback) {
    subscriptions.push(callback);

    const removeSAubscription = () => {
        const idx = subscriptions.indexOf(callback);
        if (idx > -1) {
            subscriptions.splice(idx, 1)
        }
    }
    return removeSAubscription
}

export function triggerSubscriptions(subscriptions, ...args) {
    subscriptions.slice().forEach(cb => cb(...args))
}

// 发布和订阅